<?php
class ControllerPaymentFreeCheckout extends Controller {
	protected function index() {
    	$this->data['button_confirm'] = $this->language->get('button_confirm');

		$this->data['continue'] = $this->url->link('checkout/success');

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/free_checkout.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/payment/free_checkout.tpl';
		} else {
            $this->template = 'default/template/payment/free_checkout.tpl';
        }
		
		$this->render();		 
	}
	
	public function confirm() {
		$this->load->model('checkout/order');
		
		$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('free_checkout_order_status_id'));
	}
	public function checkpwd() {
		$json = array();
		$pwd = $this->request->get['pwd'];
		$this->load->model('account/customer');
		$customerinfo = $this->model_account_customer->getCustomerByEmail($this->customer->getEmail());
      	if($customerinfo['spassword'] == md5($pwd)){
      		$this->load->model('checkout/order');
			$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('free_checkout_order_status_id'));
      		
      	}else{
      		$json['error'] = '支付密码不正确';
      		      		
      	}
      	
      	$this->response->setOutput(json_encode($json));
		
	}
	
}
?>